import factory.Factory;
import factory.Link;
import factory.Page;
import factory.Tray;

public class Main {

    private static void testLink(Factory factory){
        Link people = factory.makeLink("人民日报", "http://www.people.com.cn/");
        Link gmw = factory.makeLink("光明日报", "http://www.gmw.cn/");

        Tray traynews = factory.makeTray("日报");
        traynews.addItem(people);
        traynews.addItem(gmw);

        Link us_yahoo = factory.makeLink("Yahoo!", "http://www.yahoo.com/");
        Link jp_yahoo = factory.makeLink("Yahoo!Japan", "http://www.yahoo.co.jp/");

        Tray trayyahoo = factory.makeTray("Yahoo!");
        trayyahoo.addItem(us_yahoo);
        trayyahoo.addItem(jp_yahoo);

        Link excite = factory.makeLink("Excite", "http://www.excite.com/");
        Link google = factory.makeLink("Google", "http://www.google.com/");

        Tray traysearch = factory.makeTray("搜索引擎");
        traysearch.addItem(google);
        traysearch.addItem(excite);
        traysearch.addItem(trayyahoo);

        Page page = factory.makePage("LinkPage", "lhongyan");
        page.add(traynews);
        page.add(traysearch);
        page.output();
    }

    private static void testTable(Factory factory){
        Link people = factory.makeLink("人民日报", "http://www.people.com.cn/");
        Link gmw = factory.makeLink("光明日报", "http://www.gmw.cn/");

        Tray traynews = factory.makeTray("日报");
        traynews.addItem(people);
        traynews.addItem(gmw);

        Link us_yahoo = factory.makeLink("Yahoo!", "http://www.yahoo.com/");
        Link jp_yahoo = factory.makeLink("Yahoo!Japan", "http://www.yahoo.co.jp/");
        Tray trayyahoo = factory.makeTray("Yahoo!");
        trayyahoo.addItem(us_yahoo);
        trayyahoo.addItem(jp_yahoo);

        Link excite = factory.makeLink("Excite", "http://www.excite.com/");
        Link google = factory.makeLink("Google", "http://www.google.com/");

        Tray traysearch = factory.makeTray("搜索引擎");
        traysearch.addItem(google);
        traysearch.addItem(excite);
        traysearch.addItem(trayyahoo);

        Page page = factory.makePage("TablePage", "lhongyan");
        page.add(traynews);
        page.add(traysearch);
        page.output();
    }


    public static void main(String[] args) {
        Factory linkFactory = Factory.getFactory("listfactory.ListFactory");
        testLink(linkFactory);

        Factory tableFactory = Factory.getFactory("tablefactory.TableFactory");
        testTable(tableFactory);
    }

}
